#include<bits/stdc++.h>
using namespace std;
int n,a[200005],b[200005];
long long sum1,sum2;
int main(){
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[i]=1;
		sum1+=i;
	}
	while(sum1!=sum2){
		int l=1;
		while(b[l]==0)
		  l++;
		if(l>n)
		  break;
		cout<<l<<" ";
		b[l]=0;
		for(int i=l+1;i<=n;i++){
			if(a[i]!=a[l]&&b[i]==1){
				sum2+=i;
				cout<<i<<" ";
				l=i;
				b[l]=0;
			}
		}
		cout<<endl;
	}
	return 0;
}
